<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>修改名字</title>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui-flex.css"/>
    <style>
        body {
            font-size: 14px;
        }

        footer.aui-nav {
            z-index: 99999;
        }

        header.aui-bar {
            background: #fff;
        }

        .aui-title {
            color: #000;
        }

        .aui-nav .aui-bar-tab .active .aui-iconfont, .aui-nav .aui-bar-tab .active p {
            color: #327afa !important;
        }

        .active {
            color: #327afa !important;
        }

        .aui-tab-nav li.active {
            color: #327afa;
            border-bottom: 2px #327afa solid;
        }

        .aui-bar .aui-iconfont {
            color: #000;
        }

        .send {
            /*font-size: 12px !important;*/
        }

        .name {
            width: 80% !important;
            margin-left: 10%;
            border: none !important;
            border-bottom: 1px solid #ccc !important;
            background: transparent !important;
            margin-top: 15px;
        }
    </style>
</head>
<body>
<header class="aui-bar aui-bar-nav aui-border-b">
    <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeFrame()"></div>
    <div class="aui-title">
        修改名字
    </div>
    <div class="aui-btn aui-btn-success aui-pull-right send " onclick="save()"
         style="height: 37px;margin-top: 4px;line-height: 37px;margin-right: 15px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;">
        保存
    </div>
    <!--<div class="" tapmode onclick="send()" style="color:#327afa;">-->
    <!--保存</div>-->
</header>
<div class="contain">
    <input type="text" class="name">
</div>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/mui.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript">
    var name = "", user_name;
    apiready = function () {
        api.parseTapmode();
        name = api.pageParam.name;
        user_name = api.pageParam.user_name;
        $(".name").val(name);
        var header = $api.dom('header');
        $api.fixIos7Bar(header);

//        var header_h = $api.offset(header).h;
//        var body_h = $api.offset($api.dom('body')).h - header_h;

    }
    function save() {
        var newName = $(".name").val();
        if(newName==name){
            api.toast({
                msg:"名字没有修改，请重新输入或者返回"
            })
            return;
        }
        if (newName.trim() != "") {
            showLoading();
            var data = {};
            data['userName'] = user_name;
            data['nickname'] = newName;
            var url = 'User/memberUpdate';
            ajaxRequest(url, 'post', data, function (ret, err) {
                hideLoading();
                if (ret.status == 1) {
                    $api.setStorage('nickname', '' + newName + '');
                    api.sendEvent({
                        name:"modifyInfo",
                        extra:{
                            modify:true
                        }
                    })
                    api.closeFrame();
                    // setTimeout(function () {
                    //     api.closeFrame();
                    // },2000)

                    api.toast({
                        msg: '更新成功！',
                        duration: 2000,
                        location: 'bottom'
                    })
                } else {
                    api.toast({
                        msg: ret.msg?ret.msg:'更新出错,请重试！',
                        duration: 2000,
                        location: 'bottom'
                    })
                }
            })

        } else {
            api.toast({
                msg: "用户名不能为空"
            })
        }
    }
</script>
</html>
